package com.tesis_2.DA;
import java.util.concurrent.ExecutionException;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.tesis_2.MO.MOUser;

public class DAOSeguridad {

		
	public static MOUser Login(String user ,String pass){

		MOUser objUser = new MOUser();
		
		// aqui va lo q corte
	    try{

	    	JSONObject user1 = (new JSONReaderObject().execute(DAOUtils.getServer()+"/users/user_login/" + user +"/"+pass+".json")).get();
	    	if (user1 == null) return objUser;
	        user1 = user1.getJSONObject("user");
	        objUser.setId((Integer)user1.get("id"));
	        objUser.setName((String)user1.get("name"));
	    }catch(JSONException e)        {
	    	Log.e("log_tag", "Error parsing data "+e.toString());
	    	return objUser;
	    } catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return objUser;
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return objUser;
		}
		return objUser;

		

		
	}
}
